# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=paho-mqtt-c
_pkgname=${pkgname//-/.}
pkgver=1.3.10
pkgrel=1
pkgdesc='An Eclipse Paho C client library for MQTT.'
arch=('x86_64' 'aarch64')
url='https://github.com/eclipse/paho.mqtt.c'
license=('custom:unknown')
depends=('openssl')
makedepends=('cmake')
source=("https://github.com/eclipse/paho.mqtt.c/archive/refs/tags/v$pkgver.tar.gz")
sha512sums=('a2f7d78fe9a18603de7bf106b1bb2cf121b907947278fa444828ab75df232742be80c58fff78010a540b46b2a550206013048fba1ab69ff689a65f359e3e05bb')

build() {
  cd "$_pkgname-$pkgver"

  cmake \
    -DCMAKE_BUILD_TYPE=RelWithDebInfo \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DPAHO_WITH_SSL=TRUE \
    -DPAHO_BUILD_SAMPLES=TRUE \
    -S \
    . \
    -B build

  cmake --build build
}

package() {
  cd "$_pkgname-$pkgver"

  cmake --build build --target install -- DESTDIR="$pkgdir"

  install -Dm 644 -t "$pkgdir/usr/share/licenses/$pkgname/" LICENSE edl-v10 \
    epl-v20
}

